package tech.aistar.controller.comment;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import tech.aistar.entity.Answer;
import tech.aistar.entity.Comment;
import tech.aistar.service.comment.IAnswerService;
import tech.aistar.service.comment.ICommentService;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2019/10/4 0004.
 */
@Controller
public class AnswerController {
    @Autowired
    private IAnswerService answerService;

    @Autowired
    private ICommentService commentService;

    @RequestMapping("/answer")
    public String answerAdd(Model model,Answer answer, HttpServletRequest request){
        Answer answers = answerService.anSave(answer);
        model.addAttribute("answers",answers);

        return "redirect:comment/comment";
    }

    @RequestMapping("/commentsave")
    public String commentAdd(Model model,Comment comment, HttpServletRequest request){
//        Answer answers = answerService.anSave(answer);
        Comment comments = commentService.praiseSave(comment);
        model.addAttribute("comments",comments);

        return "redirect:comment/comment";
    }
}
